package com.maimao.model.user.sys;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.*;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.beans.Transient;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 部门
 * @author MaoLin Wang
 * @date 2020/11/28 11:11 上午
 */
@Setter
@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@TableName("sys_department")
public class Department implements Serializable {
    private static final long serialVersionUID = -4862374951556873895L;
    @TableId(type = IdType.AUTO)
    private Integer id;

    @NotBlank(message = "请填写部门名")
    private String name;

    @NotNull(message = "请选择父部门")
    @Min(value = 0,message = "参数非法")
    private Integer parentId;

    private Integer status;

    private Integer createUser;

    @TableField(exist = false)
    private String createUserName;

    private LocalDateTime createTime;

    @TableField(exist = false)
    private List<Department> children;

    private String path;

    @Override
    public String toString() {
        return "Department{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", parentId=" + parentId +
                ", status=" + status +
                ", createUserName=" + createUserName +
                ", createUser=" + createUser +
                ", createTime=" + createTime +
                ", path=" + path +
                '}';
    }
}
